<?php
$this->breadcrumbs=array(
	TextbooksModule::t('Classmate') => Yii::app()->createUrl('/textbooks/profile/index'),
	TextbooksModule::t('Edit book'),
);?>

<div class="row">
	<div class="span12">
		<?php /** @var BootActiveForm $form */
		$form = $this->beginWidget('bootstrap.widgets.BootActiveForm', array(
			'id' => 'textbook-user-course-taking-form',
			'type' => 'horizontal',
			'enableAjaxValidation' => false,
			'enableClientValidation' => true,
			'clientOptions'=>array('validateOnSubmit'=>true),
			'htmlOptions' => array(
				'class'=>'modal-form h-textbooks-form-post-book h-textbooks-course-form-add-course',
				'enctype'=>'multipart/form-data',
			),
		)); ?>
			<?php echo $form->hiddenField($model, 'thumbnail', ''); ?>
			<fieldset>
				<legend>Edit book "<?php echo CHtml::encode($model->title); ?>"</legend>
				<?php // echo $form->errorSummary($model); ?>
				<?php echo $form->dropDownListRow($model, 'department_id', CHtml::listData($departments, 'id', 'name'), array('class'=>'span3 h-textbooks-select-department-id')); ?>
				<?php echo $form->textFieldRow($model, 'isbn', array('class'=>'span3')); ?>
				<div class="control-group <?php if ($model->getError('course_id')) echo 'error'; ?>">
					<?php echo $form->labelEx($model,'course_id',array('class'=>'control-label')); ?>
					<div class="controls">
						<?php $this->widget('CAutoComplete', array(
							'model' => $model,
							'attribute' => 'course_id',
							'url' => array('/textbooks/course/suggestCourses'),
							'max' => 10,
							'minChars' => 1,
							'delay' => 500,
							'matchCase' => false,
							'htmlOptions' => array('class'=>'span3 h-textbooks-input-course-name'),
						)); ?>
						<?php echo $form->error($model,'course_id'); ?>
					</div>
				</div>
				<?php echo $form->textFieldRow($model, 'title', array('class'=>'span3')); ?>
				<?php echo $form->textFieldRow($model, 'price', array('class'=>'span3')); ?>
				<?php echo $form->textFieldRow($model, 'author', array('class'=>'span3')); ?>
				<?php echo $form->textFieldRow($model, 'description', array('class'=>'span3')); ?>
				<?php echo $form->textFieldRow($model, 'phone', array('class'=>'span3')); ?>
				<?php echo $form->textFieldRow($model, 'email', array('class'=>'span3')); ?>
				<?php // echo $form->fileFieldRow($model, 'image'); ?>
				<div class="control-group h-textbooks-book-thumbnail" style="display:none">
					<label class="control-label">Thumbnail</label>
					<div class="controls">
						<img alt="Thumbnail"/>
					</div>
				</div>
				<div class="form-actions">
					<?php $this->widget('bootstrap.widgets.BootButton', array('buttonType'=>'submit', 'type'=>'primary', 'label'=>'Edit this book', 'icon'=>'ok white')); ?>
				</div>
			</fieldset>
		<?php $this->endWidget(); ?>
	</div>
</div>